package com.ad.pet.app.account.order.view;

import android.app.Dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;

import com.ad.pet.Logger;
import com.ad.pet.R;

/**
 * Created by SEELE on 2019/1/30.
 */

public class CancelSuggestDialog extends Dialog {
    private int screenWidth;
    private  OnSubmitLinstener mOnSubmitLinstener;
    private EditText mEditText;

    public CancelSuggestDialog(@NonNull Context context) {
        super(context, R.style.custom_dialog_style);
        screenWidth = context.getResources().getDisplayMetrics().widthPixels;
        initView(context);
    }

    private void initView(Context context) {
        View view = View.inflate(context,R.layout.layout_cancel_suggest_dialog,null);
        Button btnOk = view.findViewById(R.id.btn_ok);
        ImageView ivClose = view.findViewById(R.id.iv_close);
        mEditText = view.findViewById(R.id.et_aaa);
        ivClose.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        btnOk.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mOnSubmitLinstener!=null)
                    mOnSubmitLinstener.onSubmit("", mEditText.getText().toString(),"");
            }
        });
        setContentView(view);

        Window window = this.getWindow();
        WindowManager.LayoutParams lp = window.getAttributes();
        Logger.e("screew:"+screenWidth);
        lp.width = (screenWidth *  8/ 10); // 设置宽度
//        lp.height = (int)(lp.width*1.7);
        this.getWindow().setAttributes(lp);
        window.setGravity(Gravity.CENTER);
    }

    public void setOnSubmitLinstener(OnSubmitLinstener onSubmitLinstener) {
        mOnSubmitLinstener = onSubmitLinstener;
    }


}
